package com.ctgu.蓝桥杯真题.B组2020第2场;

import java.io.*;
import java.util.Arrays;

/**
 * @author: Backdiy
 * @data: 2021/4/7 14:03
 * @desc:
 */
public class I子串分值 {
    public static void main(String[] args) throws IOException {
        String s = " ";
        s += Input.nextLine();
        int pre[] = new int[26], sum = 0;
        for (int i = 1; i < s.length(); i++) {
            sum += (i - pre[s.charAt(i) - 'a'])*(s.length()-i);
            pre[s.charAt(i)-'a'] = i;
        }
        Input.out.println(sum);
        Input.out.flush();
    }

    static class Input {
        static StreamTokenizer streamTokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        static PrintWriter out = new PrintWriter((new OutputStreamWriter(System.out)));
        static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

        static int nextInt() throws IOException {
            streamTokenizer.nextToken();
            return (int) streamTokenizer.nval;
        }

        static double nextDouble() throws IOException {
            streamTokenizer.nextToken();
            return streamTokenizer.nval;
        }

        static long nextLong() throws IOException {
            streamTokenizer.nextToken();
            return (long) streamTokenizer.nval;
        }

        static String nextLine() throws IOException {
            return bufferedReader.readLine();
        }

        static char next() throws IOException {
            return (char) bufferedReader.read();
        }
    }
}
